home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_strifle_m.cog < prev    next >
Text File  |  1998-02-25  |  4KB  |  142 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # POW_STRIFLE.COG
  4. #
  5. # POWERUP Script - Stormtrooper Rifle pickup
  6. #
  7. # [YB & CYW]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. thing       powerup                          local
  15. thing       player                           local
  16. int         bin=3                            local
  17. int         ammobin=11                       local
  18. sound       pickupsnd=thrmlpu2.wav           local
  19. sound       respawnsnd=Activate01.wav        local
  20. flex        amount                           local
  21.  
  22. int         bin_contents=0                   local
  23. int         autopickup=0                     local
  24. int         autoselect_weapon=-1             local
  25.  
  26. message     touched
  27. message     taken
  28. message     respawn
  29.  
  30. end
  31.  
  32. # ========================================================================================
  33.  
  34. code
  35.  
  36. touched:
  37.    player = GetSourceRef();
  38.    if (GetThingType(player) == 10)  // Can only be taken by players.
  39.    {
  40.       powerup = GetSenderRef();
  41.  
  42.       if(IsMulti() || (GetInv(player, bin) == 0) || (GetInv(player, ammobin) < GetInvMax(player, ammobin)))
  43.       {
  44.          TakeItem(GetSenderRef(), -1);
  45.          call taken;
  46.       }
  47.    }
  48.  
  49.    Return;
  50.  
  51. # ........................................................................................
  52.  
  53. taken:
  54.    player = GetSourceRef();
  55.    powerup = GetSenderRef();
  56.  
  57.    // Do effects.
  58.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  59.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  60.  
  61.    if(GetInv(player, bin) == 0)
  62.    {
  63.       // Pickup gun and ammo.
  64.       // Print("Stormtrooper Rifle");
  65.       jkPrintUNIString(player, bin);
  66.  
  67.       ChangeInv(player, bin, 1.0);
  68.  
  69.       // store the old bin contents
  70.       bin_contents = GetInv(player, ammobin);
  71.       ChangeInv(player, ammobin, 24.0);
  72.  
  73.       // Check for Auto Pickup
  74.       autopickup = GetAutoPickup();
  75.       if(autopickup & 1)
  76.       {
  77.          if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, bin, 0))))
  78.          {
  79.             if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  80.             {
  81.                SelectWeapon(player, bin);
  82.                Return;
  83.             }
  84.          }
  85.       }
  86.  
  87.       // Check for Auto Reload
  88.       if(GetAutoReload() & 1)
  89.       {
  90.          if(!bin_contents)
  91.          {
  92.             if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  93.             {
  94.                // Try to autoselect and see if the best weapon is an energy cell weapon
  95.                autoselect_weapon = AutoSelectWeapon(player, 2);
  96.                if((autoselect_weapon == 2) || (autoselect_weapon == 3))
  97.                   SelectWeapon(player, autoselect_weapon);
  98.             }
  99.          }
  100.       }
  101.    }
  102.    else
  103.    if(GetInv(player, ammobin) < GetInvMax(player, ammobin))
  104.    {
  105.       // Pickup ammo only.
  106.       // Print("Energy Cells");
  107.       jkPrintUNIString(player, ammobin);
  108.  
  109.       // store the old bin contents
  110.       bin_contents = GetInv(player, ammobin);
  111.  
  112.       ChangeInv(player, ammobin, 24.0);
  113.  
  114.       // Check for Auto Reload
  115.       if(GetAutoReload() & 1)
  116.       {
  117.          if(!bin_contents)
  118.          {
  119.             if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  120.             {
  121.                // Try to autoselect and see if the best weapon is an energy cell weapon
  122.                autoselect_weapon = AutoSelectWeapon(player, 2);
  123.                if((autoselect_weapon == 2) || (autoselect_weapon == 3))
  124.                   SelectWeapon(player, autoselect_weapon);
  125.             }
  126.          }
  127.       }
  128.    }
  129.  
  130.    Return;
  131.  
  132. # ........................................................................................
  133.  
  134. respawn:
  135.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  136.  
  137.    Return;
  138.  
  139. end
  140.  
  141.  
  142.